package com.arron.algorithm.leetcodetop100.字符串;



public class 字符串相加 {



    public String addStrings(String num1, String num2) {

        int i = num1.length()-1;
        int j  = num2.length()-1;


        int carray = 0;
        StringBuilder sb = new StringBuilder();
        while (i>=0 || j>=0){

            int n1 = i >= 0? num1.charAt(i) -'a' : 0;

            int n2 = j>= 0 ? num2.charAt(j) - 'a':0;

            int res = carray +n1+n2;

            carray = res /10;


            sb.append(res %10);
            i--;
            j--;

        }

        if (carray != 0){

            sb.append(carray);
        }


        return  sb.reverse().toString();
    }

}
